<?php
/**
 *
 * @author MF
 * @version 
 */
require_once 'Zend/Loader/PluginLoader.php';
require_once 'Zend/Controller/Action/Helper/Abstract.php';

/**
 * WidgetAbstract Action Helper 
 * 
 * @uses actionHelper Zend_Controller_Action_Helper
 */
class Zend_Controller_Action_Helper_WidgetAbstract extends Zend_Controller_Action_Helper_Abstract {
	/**
	 * @var Zend_Loader_PluginLoader
	 */
	public $pluginLoader;
	
	/**
	 * Constructor: initialize plugin loader
	 * 
	 * @return void
	 */
	public function __construct() {
		// TODO Auto-generated Constructor
		$this->pluginLoader = new Zend_Loader_PluginLoader ( );
	}
	
	/**
	 * This helper makes from A_SingleContent object valid array object for passing in json as widget information
	 * @param A_SingleContent $SingleContent
	 * @return array
	 */
	public function direct($SingleContent) {
		switch (get_class($SingleContent)) {
			case 'SingleHtml':
				return 
					array('html',
						array(
							'id' => $SingleContent->_content_id,
							'value' => !$SingleContent->data ? '0' : '1'
						));
				break;
			
			case 'SinglePlainText':
				return 
					array('plaintext',
						array(
							'id' => $SingleContent->_content_id,
							'value' => !$SingleContent->data ? '0' : '1'
						));
				break;
			
			case 'SingleCover':
				return 
					array('cover',
						array(
							'id' => $SingleContent->_content_id,
							'value' => !$SingleContent->file ? '0' : '1'
						));
				break;

			case 'SingleRating':
				return 
					array('rating',
						array(
							'id' => $SingleContent->_content_id,
							'value' => $SingleContent->score
						));
				break;

			case 'Comment':
				return 
					array('comments',
						array(
							'id' => $SingleContent->_content_id,
							'length' => $SingleContent->length(), //длина
							'value' => $SingleContent->nonCheckedCount //кол-во непроверенных комментов
						));
				break;

			case 'SingleGallery':
				return 
					array('gallery',
						array(
							'id' => $SingleContent->_content_id,
							'value' => $SingleContent->length()==0 ? '0' : '1'
						));
				break;

			case 'SingleBannerList':
				return 
					array('bannerlist',
						array(
							'id' => $SingleContent->_content_id,
							'value' => $SingleContent->length()==0 ? '0' : '1'
						));
				break;
				
			case 'SingleFormSender':
				return 
					array('formsender',
							array('id'=>$SingleContent->_content_id)
						);
				
				break;
			default:
				;
			break;
		}
		
	}
}

